/* 8911106 302933981 Ofri Keidar */

/******************************************************************************
* Student Name: Ofri Keidar
* Exercise Name: Ex6
* File Description: Class TooManyOrderedError's implementation
******************************************************************************/


#include "TooManyOrderedError.h"

/***************************************************************************************
* function name: TooManyOrderedError(const short invalidItem, const unsigned int invalidAmount)
* The Input: Invalid item number and invalid ordered amount
* The output: None
* The Function operation: Initializes attributes with given values
***************************************************************************************/
TooManyOrderedError::TooManyOrderedError(const short invalidItem, const unsigned int invalidAmount) {
	m_invalidItem = invalidItem;
	m_invalidAmount = invalidAmount;
}

/***************************************************************************************
* function name: TooManyOrderedError(const TooManyOrderedError& excpToCopy)
* The Input: TooManyOrderedError object to be copied
* The output: None
* The Function operation: Uses MyInventoryException's copy constructor
***************************************************************************************/
TooManyOrderedError::TooManyOrderedError(const TooManyOrderedError& excpToCopy): MyInventoryException(excpToCopy) { }

/***************************************************************************************
* function name: const char* what()
* The Input: None
* The output: Error message
* The Function operation: Uses MyInventoryException's method in order to convert invalid
* 						  item to string, then composes error message, uses MyInventoryException's
* 						  method to convert the string to char* and returns it
***************************************************************************************/
const char* TooManyOrderedError::what() {
	string invalidItemStr = "Store can't supply " + intToString(m_invalidAmount) + " items of product " + intToString(m_invalidItem);
	return stringToCharPtr(invalidItemStr);
}

